package {
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import form.ui.Alert;
	import form.ui.ApplicationContainer;
	import form.ui.BorderImage;
	import form.ui.CheckBox;
	import form.ui.FormButton;
	import form.ui.HSlider;
	import form.ui.Input;
	import form.ui.Label;
	import form.ui.LinkButton;
	import form.ui.ListBase;
	import form.ui.Radio;
	import form.ui.Select;
	import form.ui.Spacer;
	import form.ui.VSlider;
	import form.ui.component.Layout.HBox;

	[SWF(backgroundColor="0xFFFFFF", frameRate="30", width="450", height="400")]
	public class FormTest extends ApplicationContainer
	{
		private var listData:Array;
		public function FormTest()
		{
			super();
			this.layout.paddingLeft = 10;
			this.layout.paddingTop = 10;
			 
			runDefault();			
		}
		
		private function delayTest(li:ListBase):void
		{
			for(var i:int = 300; i < 350; i++)
				li.addItem({"label": i, "b": "act"});
		}
		
		public function runDefault():void
		{			
			var radioLabel:Label = new Label();
			radioLabel.formValue = "Radio Group";
			radioLabel.width = 200;
			addChild(radioLabel);
			
			var radio1:Radio = new Radio();
			radio1.label = "radio 1";
			radio1.formName = "Radio";
			radio1.width = 65;
			var radio2:Radio = new Radio();
			radio2.label = "radio 2";
			radio2.formName = "Radio";
			radio2.width = 65;
			var radio3:Radio = new Radio();
			radio3.label = "radio 3";
			radio3.formName = "Radio";
			radio3.width = 65;
			var radio4:Radio = new Radio();
			radio4.label = "radio 4";
			radio4.formName = "Radio";
			radio4.width = 65;
			
			var radioBox:HBox = new HBox();
			radioBox.percentWidth = 100;
			
			radioBox.addChild(radio1);
			radioBox.addChild(radio2);
			radioBox.addChild(radio3);
			radioBox.addChild(radio4);			
			
			addChild(radioBox);			
			
			var sp:Spacer = new Spacer();
			sp.height = 10;
			addChild(sp);
			
			var checkBoxLabel:Label = new Label();
			checkBoxLabel.formValue = "CheckBox Group";
			checkBoxLabel.width = 200;
			addChild(checkBoxLabel);
			
			var checkBox1:CheckBox = new CheckBox();
			checkBox1.label = "checkBox 1";
			checkBox1.width = 70;
			checkBox1.checkedOnAddedToStage = true;
			var checkBox2:CheckBox = new CheckBox();
			checkBox2.label = "checkBox 2";
			checkBox2.width = 70;
			var checkBox3:CheckBox = new CheckBox();
			checkBox3.label = "checkBox 3";
			checkBox3.width = 70;
			var checkBox4:CheckBox = new CheckBox();
			checkBox4.label = "checkBox 4";
			checkBox4.width = 70;
			
			var checkBoxBox:HBox = new HBox();
			checkBoxBox.percentWidth = 100;
			
			checkBoxBox.addChild(checkBox1);
			checkBoxBox.addChild(checkBox2);
			checkBoxBox.addChild(checkBox3);
			checkBoxBox.addChild(checkBox4);
			addChild(checkBoxBox);
			
			addChild(sp);
			
			var select:Select = new Select();
			select.addHeader("Default Header");
			select.addOption("Select Opinion1", "Select Opinion1");
			select.addOption("Select Opinion2", "Select Opinion2");
			select.addOption("Select Opinion3", "Select Opinion3");
			select.addOption("Select Opinion4", "Select Opinion4");
			select.addOption("Select Opinion5", "Select Opinion5");
			select.addHeader("Second Header");
			select.addOption("Select Opinion6", "Select Opinion6");
			select.addOption("Select Opinion7", "Select Opinion7");
			select.addOption("Select Opinion8", "Select Opinion8");
			select.addOption("Select Opinion9", "Select Opinion9");
			select.addSeparator();
			select.addOption("Select Opinion10", "Select Opinion10");
			select.addOption("Select Opinion11", "Select Opinion11");
			select.prompt = "Select";
			
			var input:Input = new Input();
			input.prompt = "Input";
			
			var button:FormButton = new FormButton();
			button.label = "Button";
			button.width = 80;
			button.addEventListener(MouseEvent.CLICK, showAlert, false, 0, true);		
			
			var ioBox:HBox = new HBox();
			ioBox.percentWidth = 100;
			ioBox.horizontalGap = 10;
			
			ioBox.addChild(select);
			ioBox.addChild(input);
			ioBox.addChild(button);
			addChild(ioBox);	
			
			var slideBox:HBox = new HBox();
			slideBox.percentWidth = 100;
			slideBox.height = 100;
			addChild(slideBox);
			
			var hslide:HSlider = new HSlider();
			hslide.value = 0.5;
			hslide.percentWidth = 100;
			hslide.setProgress(0.6);
			slideBox.addChild(hslide);
			
			var vslide:VSlider = new VSlider();
			vslide.value = 0.2;
			vslide.setProgress(0.5);
			vslide.percentHeight = 100;
			slideBox.addChild(vslide);
			
			var linkButton:LinkButton = new LinkButton();
			linkButton.formValue = "List";
			linkButton.upColor = 0x0;
			linkButton.hoverColor = 0x666666;
			linkButton.downColor = 0xCCCCCC;
			addChild(linkButton);
			
			listData = [];
			for(var i:int = 0; i < 200; i++)
				listData[i] = {"label": i, "b": "act"};
			
			var li:ListBase = new ListBase();
			li.percentWidth = 100;
			li.percentHeight = 100;
			addChild(li);			
			li.dataProvider = listData;
			li.selectedIndex = 180;
			
			var img:BorderImage;
		}
		
		private function showAlert(e:Event):void
		{
			
			Alert.show("Alert Title", "Alert Message");
		}
	}
}
